package cn.fancy.sdk.entity;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import cn.fancy.sdk.FancyManager;
import cn.fancy.sdk.common.utils.GuideEncodeAesRsaHelper;
import cn.fancy.sdk.common.utils.Md5;
import cn.fancy.sdk.common.utils.StringUtils;
import cn.fancy.sdk.configini.GuildConfigIni;
import cn.fancy.sdk.utils.CommMessage;
import cn.fancy.sdk.utils.JudgeSimulatorUtil;
import cn.fancy.sdk.utils.MoneyDiscountHelper;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;

@SuppressLint("NewApi")
public class GuildBaseInfo {
    
    private static final String sdk_verion_s = "1.01";
    private static Context sContext;
    
    private static String plat_user_name;
    private static String password;
    private static String game_id;
    private static String channel_id;
    
    private static String yuanpassword;
    private static String yuanpfusername;
    
    public static String login_key;
    private static GuildBaseInfo instance;
    public static String user_id;
    
    public static boolean isGuildLogin = true;
    
    private Map<String, String> LoginAuMap;
    
    private GuildBaseInfo() {
    }
    
    public static GuildBaseInfo getInstance() {
        if (null == instance) {
            instance = new GuildBaseInfo();
        }
        return instance;
    }
    
    public void init(Context ctx, String gameid, String channelid, String loginkey) {
        SharedPreferences sp = ctx.getSharedPreferences("qdz_sdk", Activity.MODE_PRIVATE);
        Editor editor = sp.edit();
        editor.putString("login_key", loginkey);
        editor.commit();
        
        login_key = loginkey;
        game_id = gameid;
        channel_id = channelid;
        LoginAuMap = new HashMap<>();
        new HashMap<String, String>();
        
        sContext = ctx;
    }
    
    public String getMetaUrl(String key) {
        try {
            ApplicationInfo applicationInfo = sContext.getPackageManager().getApplicationInfo(sContext.getPackageName(), PackageManager.GET_META_DATA);
            if (applicationInfo == null) {
                return "";
            }
            return applicationInfo.metaData.getString(key);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return "";
    }
    
    public String getMetaUrl(Context context, String key) {
        try {
            ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            if (applicationInfo == null) {
                return "";
            }
            String str = applicationInfo.metaData.getString(key);
            if (TextUtils.isEmpty(str)) {
                str = applicationInfo.metaData.get(key).toString();
            }
            return str;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
        return "";
    }
    
    public void SetLoginAuMess(String pfusername, String password,
        String authenticate) {
        if (LoginAuMap == null) {
            LoginAuMap = new HashMap<>();
        }
        
        LoginAuMap.put("plat_user_name", pfusername);
        LoginAuMap.put("password", password);
        LoginAuMap.put("authenticate", authenticate);
    }
    
    public void setAccountInfo(String pfusername, String password, String user_id) {
        if (LoginAuMap == null) {
            LoginAuMap = new HashMap<>();
        }
        
        LoginAuMap.put("plat_user_name", pfusername);
        LoginAuMap.put("password", password);
        LoginAuMap.put("user_id", user_id);
    }
    
    public Map<String, String> GetLoginAuMess() {
        return LoginAuMap;
    }
    
    public void clearLogMap() {
        if (LoginAuMap != null) {
            LoginAuMap.clear();
        }
    }
    
    public void setYuanUP(String usernmae, String passwor) {
        if (usernmae != null) {
            yuanpfusername = usernmae;
        }
        
        if (passwor != null) {
            yuanpassword = passwor;
        }
    }
    
    public void clear() {
        plat_user_name = "";
        password = "";
        user_id = "";
    }
    
    public Map<String, String> buildLoginGuild(Context mContext, String username, String passwd) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, mContext);
        
        Log.e("loginparampass", "loginparampass" + passwd);
        
        plat_user_name = username;
        password = passwd;
        yuanpassword = passwd;
        yuanpfusername = username;
        regdata.put("user_name", plat_user_name);
        regdata.put("password", Md5.md5Digest(password));
        
        reg.put("data", regdata.toString());
        reg.put("service", "login");
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, "login", tmpTime);
            reg.put("sign", keysign);
        }
        Log.e("loginparambef", "loginparambef" + regdata);
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> getRegisterNoPhoneparamsGuild(Context mContext,
        String usernamee, String passwdd, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, mContext);
        
        regdata.put("user_name", usernamee);
        regdata.put("password", Md5.md5Digest(passwdd));
        regdata.put("register_type", "1");
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        
        password = passwdd;
        yuanpassword = passwdd;
        yuanpfusername = usernamee;
        
        return reg;
    }
    
    public Map<String, String> getOneKeyMaybeNoPassParamGuild(Context mContext,
        String usernamee, String passwdd, String ac) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, mContext);
        
        regdata.put("user_name", plat_user_name);
        Log.d("RealPhoneuser", "RealPhoneuser" + plat_user_name);
        
        regdata.put("password", Md5.md5Digest(passwdd));
        Log.e("RealPhonenull2", "RealPhonenull2:" + passwdd);
        
        reg.put("data", regdata.toString());
        reg.put("service", "login");
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, ac, tmpTime);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    private void rsaRegData(Map<String, String> regData) {
        if (!GuildBaseInfo.getInstance().getMetaUrl("API_URL").contains("https")) {
            return;
        }
        
        String afterRsaUserName = GuideEncodeAesRsaHelper.getInstance().encode(regData.get("user_name"));
        String afterRsaPhone = GuideEncodeAesRsaHelper.getInstance().encode(regData.get("phone"));
        String afterRsaRealName = GuideEncodeAesRsaHelper.getInstance().encode(regData.get("realname"));
        String afterRsaIdCard = GuideEncodeAesRsaHelper.getInstance().encode(regData.get("id_card"));
        String afterRsaPassword = GuideEncodeAesRsaHelper.getInstance().encode(regData.get("password"));
        if (!TextUtils.isEmpty(afterRsaUserName)) {
            regData.put("user_name", afterRsaUserName);
        }
        if (!TextUtils.isEmpty(afterRsaPhone)) {
            regData.put("phone", afterRsaPhone);
        }
        if (!TextUtils.isEmpty(afterRsaRealName)) {
            regData.put("realname", afterRsaRealName);
        }
        if (!TextUtils.isEmpty(afterRsaIdCard)) {
            regData.put("id_card", afterRsaIdCard);
        }
        if (!TextUtils.isEmpty(afterRsaPassword)) {
            regData.put("password", afterRsaPassword);
        }
    }
    
    public Map<String, String> loginNoReal(Context mContext, String usernamee,
        String passwdd, String ac) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, mContext);
        
        regdata.put("user_name", usernamee);
        regdata.put("password", Md5.md5Digest(passwdd));
        
        reg.put("data", regdata.toString());
        reg.put("service", "login");
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (!TextUtils.isEmpty(login_key)) {
            String keysign = Md5.gBuildSign(regdata, login_key, ac, tmpTime);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> getStatisParamGuild(Context mContext, Bundle bundle, String service) {
        Map<String, String> map = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, mContext);
        
        regdata.put("type", "0");
        regdata.put("user_id", user_id);
        regdata.put("server_id", bundle.getString(FancyManager.SERVER_ID));
        regdata.put("server_name", bundle.getString(FancyManager.SERVER_NAME));
        regdata.put("role_id", bundle.getString(FancyManager.ROLE_ID));
        regdata.put("role_level", bundle.getString(FancyManager.ROLE_LEVEL));
        regdata.put("role_name", StringUtils.filterSpecialSymbols(bundle.getString(FancyManager.ROLE_NAME)));
        
        map.put("data", regdata.toString());
        map.put("service", service);
        
        String tmpTime = getTime(mContext);
        map.put("time", tmpTime);
        
        if (!TextUtils.isEmpty(login_key)) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            map.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        map.put("data", gson.toJson(regdata));
        return map;
    }
    
    public Map<String, String> getPayParamsFancy(Context context, String money, String realMoney,
        String goodsDesc, String outTradeOrder, String cpData, String paymentType, String netTime) {
        String service = "orderCreate";
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, context);
        
        regdata.put("user_id", user_id);
        regdata.put("user_name", plat_user_name);
        
        String service_id = CommMessage.mapRoleInformation.get(FancyManager.SERVER_ID) == null ?
            "" : CommMessage.mapRoleInformation.get(FancyManager.SERVER_ID);
        regdata.put("server_id", service_id);
        regdata.put("money", money);
        if (MoneyDiscountHelper.needDiscount(context)) {
            regdata.put("real_money", realMoney);
        }
        
        regdata.put("payment_type", paymentType);
        regdata.put("cp_order", outTradeOrder);
        
        String filterCpData = StringUtils.filterSpecialSymbols(cpData);
        regdata.put("cp_data", filterCpData);
        regdata.put("goods_name", money);
        
        regdata.put("desc", goodsDesc);
        regdata.put("gain", money);
        
        String role_id = CommMessage.mapRoleInformation.get(FancyManager.ROLE_ID) == null ?
            "" : CommMessage.mapRoleInformation.get(FancyManager.ROLE_ID);
        regdata.put("role_id", role_id);
        
        String role_name = CommMessage.mapRoleInformation.get(FancyManager.ROLE_NAME) == null ?
            "" : CommMessage.mapRoleInformation.get(FancyManager.ROLE_NAME);
        regdata.put("role_name", StringUtils.filterSpecialSymbols(role_name));
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(context);
        reg.put("time", netTime);
        
        if (!TextUtils.isEmpty(login_key)) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, netTime);
            reg.put("sign", keysign);
            Log.e("getPayParamsFancySign", keysign);
        }
        rsaRegData(regdata);
        
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    // 一键注册
    public Map<String, String> oneKeyRegisterParamsGuild(Context mContext, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, mContext);
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            // arg3是服务名称
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            Log.e("test===", keysign);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> realParamReq(Context mContext, String username,
        String password, String peoplename, String peoplesign, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        
        addPublicParam(regdata, mContext);
        regdata.put("user_name", username);
        regdata.put("password", Md5.md5Digest(password));
        regdata.put("realname", peoplename);
        regdata.put("id_card", peoplesign);
        regdata.put("valid_type", "1");
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        
        return reg;
    }
    
    public Map<String, String> resetPassParam(Context mContext, String user_name,
        String password, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        
        addPublicParam(regdata, mContext);
        regdata.put("user_name", user_name);
        regdata.put("password", Md5.md5Digest(password));
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        
        return reg;
    }
    
    public Map<String, String> getRegisterSmsCodeParamsGuide(Context mContext,
        String uphone, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        
        addPublicParam(regdata, mContext);
        regdata.put("phone", uphone);
        regdata.put("type", "1");
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            // arg3是服务名称
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> getSmscodeParamsWithPassGuide(Context mContext,
        String uphone, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        
        addPublicParam(regdata, mContext);
        regdata.put("type", "1");
        regdata.put("phone", uphone);
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            // arg3是服务名称,即是原来的action
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            Log.e("sign", keysign);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> getQuickRegisterParamsGuild(Context mContext,
        String uphone, String upassword, String umess, String service, String username) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        
        addPublicParam(regdata, mContext);
        regdata.put("phone", uphone);
        regdata.put("password", Md5.md5Digest(upassword));
        regdata.put("verify", umess);
        regdata.put("register_type", "3");
        regdata.put("user_name", username);
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        rsaRegData(regdata);
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> phoneRegisterParams(Context mContext,
        String uphone, String upassword, String umess, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        
        addPublicParam(regdata, mContext);
        regdata.put("phone", uphone);
        regdata.put("password", Md5.md5Digest(upassword));
        regdata.put("register_type", "2");
        regdata.put("verify", umess);
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> switchRegisterPanelParams(Context context, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        
        addPublicParam(regdata, context);
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(context);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> buildFloatWebParamGuild(Context context) {
        LinkedHashMap<String, String> map = new LinkedHashMap<>();
        map.put("game_id", game_id);
        map.put("user_id", user_id);
        map.put("time", getTime(context));
        String keysign = Md5.buildSignNotAnd(map, login_key);
        map.put("sign", keysign);
        map.put("device", "Android");
        
        return map;
    }
    
    public Map<String, String> getFindPassUserListParams(Context mContext, String phone, String smscode, String service) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        
        addPublicParam(regdata, mContext);
        regdata.put("verify", smscode);
        regdata.put("phone", phone);
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> buildgetBindParamsMain(Context mContext, String userphone,
        String service, String code, String user_id) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, mContext);
        
        regdata.put("phone", userphone);
        regdata.put("verify", code);
        
        regdata.put("user_id", user_id);
        
        reg.put("data", regdata.toString());
        reg.put("service", service);
        
        String tmpTime = getTime(mContext);
        reg.put("time", tmpTime);
        
        if (login_key != null && !login_key.equals("")) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        Gson gson = new GsonBuilder().disableHtmlEscaping().create();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
    
    public Map<String, String> sendIsSimulator(Context context, String userName, int type) {
        String action = "verifyUser";
        Map<String, String> reg = new TreeMap<>();
        addPublicParam(reg, context);
        reg.put("user_name", userName);
        reg.put("type", String.valueOf(type));
        reg.put("service", action);
        return reg;
    }
    
    private void addPublicParam(Map<String, String> regg, Context context) {
        if (regg == null) {
            return;
        }
        HashMap<String, String> mapGuild = GuildConfigIni.getParams();
        
        String channelId = mapGuild.get("channelid");
        if (channelId.length() == 3) {
            String tempChannelId = channelId;
            if (tempChannelId.charAt(0) == '0') {
                tempChannelId = tempChannelId.substring(1);
                if (tempChannelId.charAt(0) == '0') {
                    tempChannelId = tempChannelId.substring(1);
                    
                }
            }
            channelId = tempChannelId;
        }
        
        regg.put("channel_id", channelId);
        regg.put("extension", "");
        regg.put("game_id", mapGuild.get("gameid"));
        regg.put("imei", getIMEI(context));
        regg.put("login_type", "1");
        regg.put("device", "Android");
        regg.put("model", getModel());
        regg.put("macAddress", getLocalMacAddress(context));
        regg.put("valid_type", "1");
        regg.put("sdkVersion", getSdkVersion());
        regg.put("system_version", "Android_" + android.os.Build.VERSION.RELEASE);
        regg.put("isSimulator", JudgeSimulatorUtil.simulatorParams(context));
    }
    
    private String getModel() {
        return "" + Build.BRAND
            + "_"
            + Build.MODEL;
    }
    
    public static void setAcctsInfo(String username, String userid, String passwd) {
        plat_user_name = username;
        user_id = userid;
        password = passwd;
    }
    
    public String getLocalMacAddress(Context context) {
        String Mac = "02:00:00:00:00:00";
        return Mac;
    }
    
    private String getSystemVersion() {
        
        if (android.os.Build.VERSION.RELEASE == null
            || android.os.Build.VERSION.RELEASE.equals("")) {
            return "default";
        }
        
        return android.os.Build.VERSION.RELEASE;
    }
    
    private String getDevType() {
        
        if (android.os.Build.MODEL == null || android.os.Build.MODEL.equals("")) {
            return "default";
        }
        return android.os.Build.MODEL;
    }
    
    public String getIMEI(Context mContext) {
        return "default";
    }
    
    private String getSdkVersion() {
        return sdk_verion_s;
    }
    
    public String getNetworkType(Context mContext) {
        String network = "default";
        return network;
    }
    
    public String getUserName() {
        Log.e("getplat_user_name", "getplat_user_name" + plat_user_name);
        return plat_user_name;
    }
    
    public String getYuanpassword() {
        return yuanpassword;
    }
    
    public String getYuanpfusername() {
        return yuanpfusername;
    }
    
    public void ResetPassword(String pass) {
        if (pass != null && !pass.equals("")) {
            yuanpassword = pass;
            password = Md5.md5Digest(pass);
        }
    }
    
    // 增加外用设备数据
    // 加上公用数据
    public void addDeviceMess(Map<String, String> reg, Context mContext) {
        if (reg == null) {
            return;
        }
        reg.put("game_id", game_id);
        reg.put("channel_id", channel_id);
        reg.put("sdk_version", getSdkVersion());
        reg.put("mac", getLocalMacAddress(mContext));
        reg.put("package_name", mContext.getPackageName());
        reg.put("system_version", getSystemVersion());
        reg.put("system_type", "android");
        reg.put("network_type", getNetworkType(mContext));
        reg.put("device_type", getDevType());
    }
    
    public static String getTime(Context context) {
        if (JudgeSimulatorUtil.judgeTrueDevice(context)) {
            return getLocalTime();
        }
        return getNetTime();
    }
    
    private static String getLocalTime() {
        long time = System.currentTimeMillis() / 1000;  // 获取系统时间的10位的时间戳
        return String.valueOf(time);
    }
    
    private static String getNetTime() {
        try {
            URL url = new URL("http://www.baidu.com");
            URLConnection uc = url.openConnection();
            uc.connect();
            uc.setConnectTimeout(5000);
            long ld = uc.getDate() / 1000;
            return String.valueOf(ld);
        } catch (IOException e) {
            e.printStackTrace();
        }
        return getLocalTime();
    }
    
    //充值火山广告上报
    public Map<String, String> advertPayUploadParam(Context context, String order_no) {
        Map<String, String> reg = new TreeMap<>();
        Map<String, String> regdata = new TreeMap<>();
        addPublicParam(regdata, context);
        regdata.put("order_no", order_no);
        
        String service = "orderQuery";
        reg.put("data", regdata.toString());
        reg.put("service", service);
        String tmpTime = getTime(context);
        reg.put("time", tmpTime);
        
        if (!TextUtils.isEmpty(login_key)) {
            String keysign = Md5.gBuildSign(regdata, login_key, service, tmpTime);
            reg.put("sign", keysign);
        }
        
        Gson gson = new Gson();
        reg.put("data", gson.toJson(regdata));
        return reg;
    }
}
